/*
 * pearl.h
 *
 *  Created on: 05/12/2009
 *      Author: Kimi
 */

#ifndef PEARL_H_
#define PEARL_H_

#include "lpc213x.h"

#define PEARL_INPUT_DIR			IODIR0
#define PEARL_INPUT_PIN			IOPIN0
#define PEARL_OUTPUT_DIR		IODIR0
#define PEARL_OUTPUT_SET		IOSET0
#define PEARL_OUTPUT_CLEAR		IOCLR0

#define PEARL_CENTER_PIN		26
#define PEARL_UP_PIN			30
#define PEARL_DOWN_PIN			29
#define PEARL_LEFT_PIN			28
#define PEARL_RIGHT_PIN			27

#define PEARL_DIRECTION_NONE 	0
#define PEARL_DIRECTION_UP	 	1
#define PEARL_DIRECTION_DOWN 	2
#define PEARL_DIRECTION_LEFT 	4
#define PEARL_DIRECTION_RIGHT	8

#define PEARL_BLUE				16
#define PEARL_RED				15
#define PEARL_GREEN				12
#define PEARL_WHITE				13

#define PEARL_LIGHT_ON			1
#define PEARL_LIGHT_OFF			0

void pearl_Init();

unsigned char pearl_GetDirection();
unsigned char pearl_IsCenterPressed();

unsigned char pearl_IsMovingRight();
unsigned char pearl_IsMovingLeft();

#ifdef PEARL_RED
void pearl_RedLight(unsigned char state);
#endif

#ifdef PEARL_GREEN
void pearl_GreenLight(unsigned char state);
#endif

#ifdef PEARL_BLUE
void pearl_BlueLight(unsigned char state);
#endif

#ifdef PEARL_WHITE
void pearl_WhiteLight(unsigned char state);
#endif

void pearl_TestLights();

#endif /* PEARL_H_ */
